home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2884 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.2 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: landen.math.uwaterloo.ca!tthiraku
  3. From: tthiraku@landen.math.uwaterloo.ca (Thanou Thirakul)
  4. Subject: [] overload..(newbie in distress)
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <DLGppJ.31C@undergrad.math.uwaterloo.ca>
  7. Date: Sat, 20 Jan 1996 04:27:19 GMT
  8. Nntp-Posting-Host: landen.math.uwaterloo.ca
  9. Organization: University of Waterloo
  10.  
  11. Hi..
  12.  
  13. I'm currently stuck on how to overload [] operator such that
  14. it does two different tasks..
  15.  
  16.  
  17. case 1:
  18.  
  19. // A is an instance of a class that contains a linkist.
  20.  
  21.    A[5] = val;  // store val into the fifth node of a linklist. 
  22.    val = A[5] ; // returns the value of the fifth node of a linklist.  
  23.  
  24.  
  25. I was wondering how can C++ differentiate these two senerios? 
  26.  
  27. Anything help will greatly appreciated..
  28.  
  29. Thank You Kindly
  30. -- 
  31. Thanou Thirakul
  32. tthiraku@undergrad.math.uwaterloo.ca
  33. http://www.undergrad.math.uwaterloo.ca/~tthiraku
  34.  ___________________________________________________________
  35. |                                |
  36. | <after submitting a CS assignment>                |
  37. |                                |
  38. |  "Well, that was the most well-documented non-working     |
  39. |   piece of code I have ever written.. " -unknown          |
  40. |                                |
  41. |___________________________________________________________|
  42.